<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>系统首页</title>
    <link rel="stylesheet" href="{$CSS}/bootstrap3.3.7.min.css">
    <style>
        em{
            font-size: 20px;
            color: red;
            vertical-align: middle;
            line-height: 20px;
            height: 20px;
            display: inline-block;
        }
        .mar{
            margin-right:10px
        }
        .pic{
        	float:none;margin-bottom:10px
        }
        .pic img{
        	width: 393px;
    		height: 75px;
    	}
    </style>
</head>
<body style="overflow-x:hidden;">
    <div style="padding:10px;border-bottom:1px solid #eee;font-size:15px;font-weight:700">{if $slideManage->id}修改幻灯片{else}新增幻灯片{/if}</div>
    <div style="margin:40px auto;">
        <div class="bs-example" data-example-id="simple-horizontal-form">
            <form class="form-horizontal" method="post" action=""  id="regform">{tk()}{$slideManage->hidden('id')}
                <div class="form-group">
                  <label class="col-sm-2 control-label">幻灯片</label>
                     <div class="col-sm-8">
                       <img class="thumb_img" onerror="this.style.display='none'" src="{$slideManage->pic}" id="pic_pic" relobj="elfinder_pic" style=" width: 300px; height: 75px;" />
                       {$slideManage->hidden('pic')}
                        <button class="btn btn-default select_img" type="button" data-target="pic">选择图片</button>
                        <span class="help-inline"></span>
                      </div>
                </div>
                <div class="form-group">
                    <label for="inputPassword3" class="col-sm-2 control-label">一级标题</label>
                    <div class="col-sm-3">
						{$slideManage->text('one_title','class="form-control" placeholder="一级标题"')}
						<span class="help-inline"></span>
                    </div>
                </div>
				<div class="form-group">
                    <label for="inputPassword3" class="col-sm-2 control-label">二级标题</label>
                    <div class="col-sm-3">
						   {$slideManage->text('two_title','class="form-control" placeholder="二级标题"')}
                    </div>
                </div>
				<div class="form-group">
                    <label for="inputPassword3" class="col-sm-2 control-label">二级标题</label>
                    <div class="col-sm-3">
						   {$slideManage->text('twot_title','class="form-control" placeholder="二级标题"')}
                    </div>
                </div>
				<div class="form-group">
                    <label for="inputPassword3" class="col-sm-2 control-label">按钮文本</label>
                    <div class="col-sm-3">
						   {$slideManage->text('buttonText','class="form-control" placeholder="按钮文本"')}
                    </div>
                </div>
				<div class="form-group">
                    <label for="inputPassword3" class="col-sm-2 control-label">跳转链接</label>
                    <div class="col-sm-3">
						 {$slideManage->text('url','class="form-control" placeholder="需填写http或https"')}
						 <span class="help-inline"></span>
                    </div>
                </div>
				<div class="form-group">
                    <label for="inputPassword3" class="col-sm-2 control-label">排序</label>
                    <div class="col-sm-3">
						   {$slideManage->text('sort','class="form-control" placeholder="排序"')}
                    </div>
                </div>
                <div class="form-group">
                   <label for="inputPassword3" class="col-sm-2 control-label"></label>
                    <div class="col-sm-6">
						<input class="btn btn-success mar" type="hidden" name="action" value="add" />
                        <input class="btn btn-success mar" name="btnAdd" ID="btnAdd" onclick="registerUser()" type="button" class="button" value="提交">
                        <input class="btn btn-warning mar" name="reset" ID="Submit1" type="reset" value="重置">
                        <input class="btn btn-danger mar"  name="back" ID="back" type="button" onclick="history.back();" value="返回">
                        </div>
                </div>
				
            </form>
        </div>

    </div>
</body>

</html>
<script type="text/javascript">
	
	function registerUser(){  
		$('.help-inline').remove();
		$('font').css('display','none')
		$('#regform').validate(function(m){
		    if(m.length>0){
		        for(var i=0;i<m.length;i++){
		            //m[i].e为验证错误的表单元素
		            //m[i].m该单元的错误信息（非空错误为false，其他为信息数组）
		 			var ntip = $('<span class="help-inline" style="color:red">'+(m[i].m===false?'该项内容不能为空':m[i].m.join(','))+'</span>');
		            $(m[i].e).after(ntip.show());
		            $(m[i].e).one('blur',function(){
		            	ntip.remove();
		            });
		        }
		    }else{
		        $('form').submit();
		    }
		});
	}
</script>
<script src="/layui/layui.js"></script>
<script>
layui.use(['element', 'layer', 'upload'], function () {
  var layer = layui.layer;
});
$('.select_img').on('click',function  () {
  var targetId=this.getAttribute('data-target');
  layer.open({
    title:'图片库',
    type: 2,
    area: ['700px', '450px'],
    fixed: false, //不固定
    maxmin: false,
    content: '/imgLib/libs.html?type=vshop_img&target='+targetId
  });
})

window.uploadImgCallback=function (tgt,url) {
  console.log('选择图片结果',tgt,url);
   if(tgt=='pic'){
	var inputEle=$('#pc_slide_managepic');
    var prevEle=$('#pic_pic');
    inputEle.val(url);
    prevEle.attr('src',url);
	prevEle.show();
  }
};

</script>  